package wechat.start.wechatstart.entity;

import lombok.Data;

/**
 * Created by WuJiXian on 2020/12/5 10:57
 */
@Data
public class AccessToken {
    private String accessToken;
    // 存放的过期时间
    private long expireTime;

    public AccessToken(String accessToken, String expiresIn) {
        this.accessToken = accessToken;
        // 确定token的过期时间
        this.expireTime = System.currentTimeMillis() + Integer.parseInt(expiresIn) * 1000;
    }

    /*
        判断token是否过期:当前时间大于过期时间说明已经过期
     */
    public boolean isExpired() {
        return System.currentTimeMillis() > expireTime;
    }
}
